import {defineStore} from 'pinia'
import {useRequest} from "@/hooks/useRequest";

export const useMainStore = defineStore('storeId', {
    state: () => ({
        id: 'main',
        name: '超级管理员',
        count: 0,
        data: {}
    }),
    actions: {
        increment() {
            this.count += 10
        },
        randomizeCounter() {
            this.count = Math.round(100 * Math.random())
        },
        async getRequestData(url = 'data/data.json') {
            this.data = await useRequest(url)
        }
    },
    getters: {
        nameLength: (state) => state.name.length
    }
})